﻿namespace Company.Plc
{
    public interface IPlc
    {
        /// <summary>
        /// 是否初始化
        /// </summary>
        bool Initialized { get; }
        /// <summary>
        /// 连接状态
        /// </summary>
        bool Connected { get; }
        /// <summary>
        /// 运行消息
        /// </summary>
        string Message { get; }
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="config">配置参数</param>
        /// <returns></returns>
        bool Init(PlcConfig config);
        /// <summary>
        /// 关闭硬件
        /// </summary>
        void Close();
        /// <summary>
        /// 读PLC
        /// </summary>
        /// <param name="address">地址</param>
        /// <param name="length">长度</param>
        /// <returns></returns>
        ushort[] Read(string address, ushort length);
        /// <summary>
        /// 写单个寄存器
        /// </summary>
        /// <param name="address">地址</param>
        /// <param name="value">写入值</param>
        /// <returns></returns>
        bool Write(string address, ushort value);
        /// <summary>
        /// 写多个寄存器
        /// </summary>
        /// <param name="address">地址</param>
        /// <param name="value">写入值数组</param>
        /// <returns></returns>
        bool Write(string address, ushort[] value);
    }
}
